import grails.test.GrailsUnitTestCase
import grails.test.MockUtils

class JobTests extends GrailsUnitTestCase{
    public void testNullableConstraints() {
        // Mock the validate() method.
        registerMetaClass(Job)
        MockUtils.prepareForConstraintsTests(Job)

        def testInstance = new Job()
        def errors = testInstance.validate()
        assertEquals 3, errors.size()
        assertEquals "nullable", errors["jobName"]
        assertEquals "nullable", errors["body"]
        assertEquals "nullable", errors["headline"]
    }

    public void testBlankConstraints() {
        // Mock the validate() method.
        registerMetaClass(Job)
        MockUtils.prepareForConstraintsTests(Job)

        def testInstance = new Job(jobName: '  ', body:' ', headline:' ')
        def errors = testInstance.validate()
        assertEquals 3, errors.size()
        assertEquals "blank", errors["jobName"]
        assertEquals "blank", errors["body"]
        assertEquals "blank", errors["headline"]
    }
}